﻿<UserControl x:Class="SMS.Views.Master.CustomerMaster"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             d:DesignHeight="600"
             d:DesignWidth="700"
             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
             xmlns:my="clr-namespace:SMS.Controls;assembly=SMS.Controls"
             xmlns:my1="clr-namespace:SMS.Views.Master">

    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="280" />
                <ColumnDefinition Width="3" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Border BorderBrush="Black"
                    BorderThickness="1">
                <Grid Margin="5">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="5" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Rectangle Grid.Row="1"
                               Style="{StaticResource SeperatorRectangle}"
                               Grid.ColumnSpan="1" />
                    <StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <my:SMSCustomer Width="150"
                                            SelectedCustomer="{Binding Path=SelectedMaster, Mode=TwoWay}"
                                            SearchText="{Binding Path=SearchText, Mode=TwoWay}" />

                            <Button Content="Go"
                                    Command="{Binding Path=SearchCommand}"
                                    Width="50" />
                        </StackPanel>
                    </StackPanel>
                    <sdk:DataGrid AutoGenerateColumns="False"
                                  x:Name="dgList"
                                  ItemsSource="{Binding Path=PagedCustomerList}"
                                  SelectedItem="{Binding Path=SelectedMaster, Mode=TwoWay}"
                                  Grid.Row="2"
                                  IsReadOnly="True">
                        <sdk:DataGrid.Columns>
                            <sdk:DataGridTextColumn Header="Customer ID"
                                                    Binding="{Binding Path=Customer_ID}" />
                            <sdk:DataGridTextColumn Header="Customer Name"
                                                    Binding="{Binding Path=Customer_Name}" />
                        </sdk:DataGrid.Columns>
                    </sdk:DataGrid>
                </Grid>
            </Border>

            <Border Grid.Column="2"
                    BorderBrush="Black"
                    BorderThickness="1">
                <Grid Margin="5"
                      DataContext="{Binding Path=SelectedMaster}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition Width="4" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="15" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="5" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="5" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="5" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="5" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="5" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="5" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="5" />
                        <RowDefinition Height="*" />
                        <RowDefinition Height="5" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <TextBlock Text="CUSTOMER MASTER"
                               FontSize="15" />
                    <TextBlock Text="Customer ID"
                               Grid.Row="2" />
                    <Rectangle Grid.Row="1"
                               Style="{StaticResource SeperatorRectangle}"
                               Grid.ColumnSpan="3" />
                    <Rectangle Grid.Row="3"
                               Style="{StaticResource SeperatorRectangle}"
                               Grid.ColumnSpan="3" />
                    <Rectangle Grid.Row="5"
                               Style="{StaticResource SeperatorRectangle}"
                               Grid.ColumnSpan="3" />
                    <Rectangle Grid.Row="7"
                               Style="{StaticResource SeperatorRectangle}"
                               Grid.ColumnSpan="3" />
                    <Rectangle Grid.Row="9"
                               Style="{StaticResource SeperatorRectangle}"
                               Grid.ColumnSpan="3" />
                    <Rectangle Grid.Row="11"
                               Style="{StaticResource SeperatorRectangle}"
                               Grid.ColumnSpan="3" />
                    <Rectangle Grid.Row="13"
                               Style="{StaticResource SeperatorRectangle}"
                               Grid.ColumnSpan="3" />
                    <TextBox Text="{Binding Path=Customer_ID}"
                             IsReadOnly="True"
                             Grid.Row="2"
                             Grid.Column="2" />

                    <TextBlock Text="Customer Name"
                               Grid.Row="4" />
                    <TextBox Grid.Row="4"
                             Grid.Column="2"
                             Text="{Binding Path=Customer_Name, Mode=TwoWay}" />
                    <TextBlock Text="Customer Address"
                               Grid.Row="6" />
                    <TextBox Grid.Row="6"
                             Text="{Binding Path=Customer_Address, Mode=TwoWay}"
                             Grid.Column="2" />
                    <TextBlock Text="Mobile"
                               Grid.Row="8" />
                    <TextBox Grid.Row="8"
                             Grid.Column="2"
                             Text="{Binding Path=Customer_Mobile, Mode=TwoWay}" />
                    <TextBlock Text="Alt Mobile"
                               Grid.Row="10" />
                    <TextBox Grid.Row="10"
                             Grid.Column="2"
                             Text="{Binding Path=Customer_AlterMobile, Mode=TwoWay}" />
                    <TextBlock Text="Credit Limit"
                               Grid.Row="12" />
                    <TextBox Grid.Row="12"
                             Grid.Column="2"
                             Text="{Binding Path=Customer_CreditLimit, Mode=TwoWay}" />
                    <TextBlock Text="Is Active"
                               Grid.Row="14" />
                    <CheckBox Grid.Row="14"
                              Grid.Column="2"
                              VerticalAlignment="Center"
                              HorizontalAlignment="Left"
                              IsChecked="{Binding Path=IsLive, Mode=TwoWay}" />
                    <Button Content="Show Transactions..."
                            Grid.Row="18"
                            Grid.ColumnSpan="3"
                            Command="{Binding Path=LoadTransactionCommand}"
                            DataContext="{Binding Path=DataContext, ElementName=LayoutRoot}"
                            VerticalAlignment="Top"
                            HorizontalAlignment="Right" />
                </Grid>
            </Border>
        </Grid>
        <sdk:DataPager HorizontalAlignment="Left"
                       Grid.Row="1"
                       Source="{Binding Path=ItemsSource, ElementName=dgList}"
                       Width="250"
                       PageSize="10" />
        <StackPanel HorizontalAlignment="Right"
                    Orientation="Horizontal"
                    Grid.Row="1">
            <Button Content="New"
                    Width="75"
                    Command="{Binding Path=NewCommand}" />
            <Button Content="Save"
                    Command="{Binding Path=SaveCommand}"
                    Width="75"
                    Margin="5,0" />
            <Button Content="Cancel"
                    Width="75"
                    Command="{Binding Path=CancelCommand}" />
        </StackPanel>
        <Grid Grid.Row="3">
            <my:ErrorControl HorizontalAlignment="Left"
                             Name="errorControl1"
                             VerticalAlignment="Top" />
        </Grid>
    </Grid>
</UserControl>
